/**[100,4,200,1,3,2]
 * @param {number[]} nums
 * @return {number}
 */
var longestConsecutive = function(nums) {
    let ans = 0
    const st = new Set(nums)
    for(const x of st){
        if(st.has(x-1)){
            continue
        }
        let y = x+1
        while(st.has(y)){
            y++
        }
        ans = y-x
    }
    return ans
};
const result  = longestConsecutive([100,4,200,1,3,2])
console.log("🚀 ~ result:", result)
